<!--Sub-menu-->
<?php require __DIR__ . '/../_submenu.php'; ?>

<h1>Import Stock From File</h1>
<?php Yii::getPathOfAlias('webroot'); ?>
<?php echo CHtml::form('', 'post', array('enctype'=>'multipart/form-data')); ?>
    <?php echo CHtml::errorSummary($form); ?>

    <!-- Radio Buttons-->
    <div class="RadioButtons">
        <?php echo CHtml::activeLabel($form,'File Type'); ?>
        <?php echo CHtml::radioButtonList('fileType', 'xls', array('xls'=>'CVS')) ?>
    </div>

    <!--Upload file box-->
    <?php echo CHtml::activeLabel($form,'Upload'); ?>
    <?php echo CHtml::activeFileField($form, 'file'); ?>
    <br/>
   
    <!--Preview Button-->
    <?php echo CHtml::submitButton('Preview'); ?>

    <!--Import Button-->
    <?php
        if ($dir == '') { /*echo CHtml::ajaxSubmitButton("Start Import",
            CController::createUrl('stock/UpdateAjax'),
            array('update' => '#status'));*/
        } else {
           echo '<br>Exchange <select id="houseTem" name="houseTem" class="houseTem" disabled>';
           if($_SESSION['house']=="HOSE") echo '<option SELECTED value="1">HOSE</option>'; else echo '<option value="1">HOSE</option>';
           if($_SESSION['house']=="HNX") echo '<option SELECTED value="2">HNX</option>'; else echo '<option value="2">HNX</option>'; 
           if($_SESSION['house']=="UPCOM") echo '<option SELECTED value="4">UPCOM</option>'; else echo '<option value="4">UPCOM</option>'; 
           echo '</select>';
            echo CHtml::ajaxSubmitButton("Start Import",
                CController::createUrl('stock/UpdateAjax', array('dir' => $dir)),
                array(
                    'beforeSend' => "js:function(){ $('#status').html('Importing ...'); }",
                    'complete'   => "js:function(){
                        $('#status').html('Done');
                        $('#status').removeClass('loading'); }",
                            'update'     => '#status')
                        );
                        echo $_SESSION['house'];
        }
    ?>
<div id="status"></div>
<?php echo CHtml::endForm(); ?>

<!-- Display GridView -->
<div id="data">
<?php $this->renderPartial(
    'importFromFile/_importFromFile',
    array('dataProvider'=>$dataProvider));
?>
</div>
